The present invention relates in general to image graphics and more particularly to a method and system for implementing graphics control constructs.
Graphics rendering and other visualization applications typically utilize accelerated hardware, firmware, and in some cases software modules to perform compute-intensive rendering operations. These applications also utilize a graphics system interface such as OPENGL(copyright) or DIRECT3D(copyright) to control low-level graphics drawing operations in these accelerated modules. These operations include, but are not limited to, polygon specification and transformations, basic lighting control, and frame buffer operations such as blending and depth-buffering. Transformations usually correctly position one or more three-dimensional objects and then apply lighting and/or textures using the correct size and angles. OPENGL(copyright) utilizes a variety of low-level models such as textures, which may be defined for objects within scenes, and lighting models, which may define light sources and the manner in which surfaces in the scenes reflect light therefrom. Unfortunately, any increase in the quality of an object""s appearance is typically associated with a decrease in processing speed. This decrease in processing speed is undesirable, especially for interactive applications.
Although these interfaces provide low-level models of graphics operations that may be performed by accelerated modules, they typically process geometry-based data, and thus limit the flexibility with which pixel-based complex effects may be programmed. For example, programmable or procedural shading applications usually involve pixel-based manipulation of the appearances of objects within a scene by an artist or technical director. Controlling the appearance of these objects typically requires the use of complex effects such as blending, shading and texturing. For example, the artist may desire that a portion of a reflecting pool appear rippled and bright. These applications are desirably programmable to improve the flexibility and speed of manipulating the objects to achieve the desired result. Unfortunately, these applications typically may not use graphics system interfaces such as OPENGL(copyright) in conjunction with conditional constructs so that only those selected pixels within a region will be affected as the artist desires.
From the foregoing, it may be appreciated that a need has arisen for providing a method for allowing software applications to utilize graphics pipelines to flexibly and easily alter the appearances of image objects. In accordance with the present invention, a method and system for implementing graphics control constructs are provided that substantially eliminate or reduce disadvantages and problems of conventional systems.
One aspect of the invention is a method for implementing a graphics control construct. The method includes the step of assigning by a graphics system interface a value to at least one bit in a stencil buffer in response to a first condition of a first conditional clause in an application program. The method also includes the steps of selecting at least a first portion of image data in response to the value, and processing the selected first portion of image data in a frame buffer of a graphics pipeline. The invention provides several important advantages over conventional systems. Various embodiments of the invention may have none, some, or all of these advantages. For example, one technical advantage of the present invention is that it may be used to implement conditional statements using a graphics system interface in conjunction with accelerated processing. This advantage allows an interface such as OPENGL(copyright) to be used as a single-instruction, multiple-data (SIMD) computing surface. Such an advantage may allow per-pixel computations to be evaluated so that different functions, such as texturing and shading, may be applied to selected regions, rather than on a rectilinear basis typically required by conventional systems. Such an advantage may improve the quality of the resultant shading and/or appearance. Another technical advantage of the present invention is that it may be used with a variety of existing systems with little or no impact on the speed of processing. Other technical advantages may be readily ascertainable by those skilled in the art from the following figures, description, and claims.